package com.yundahh.u8c.dao;

import com.fasterxml.jackson.core.type.TypeReference;
import com.yundahh.u8c.config.U8CConfig;
import com.yundahh.u8c.dao.base.U8CBaseDao;
import com.yundahh.u8c.entity.doc.BaseDocChild;
import com.yundahh.u8c.entity.doc.BaseDocParent;
import com.yundahh.u8c.entity.base.BaseVO;
import com.yundahh.u8c.entity.base.U8CResult;
import com.yundahh.u8c.enums.OperationType;
import com.yundahh.u8c.util.JsonUtils;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

public class BaseDocDao extends U8CBaseDao<BaseVO<BaseDocParent, BaseDocChild>> {



    public BaseDocDao(U8CConfig config) {
        super(config);
    }



    @Override
    public String getApiUrl() {
        return "/u8cloud/api/uapbd/invbasdoc";
    }

    public boolean update(BaseDocParent baseDocParent){
        List<BaseVO<BaseDocParent, BaseDocChild>> list =new ArrayList<>();
        list.add(new BaseVO<BaseDocParent, BaseDocChild>());
        list.get(0).setParentvo(baseDocParent);
        String json="{\"invbasdoc\":"+JsonUtils.object2Json(list)+"}";
        System.out.println(json);
        try {
            U8CResult<BaseVO<BaseDocParent, BaseDocChild>> send = send(OperationType.UPDATE, json);
            if(send.getStatus().equals("success"))
                return true;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return false;
    }
}
